package app;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

import javax.security.auth.callback.ConfirmationCallback;

public class Main extends Application {

    private static volatile double xOffset = 0;
    private static volatile double yOffset = 0;

    @Override
    public void start(Stage primaryStage) throws Exception{
        //读取fxml配置信息，构建视图结点
        Parent root = FXMLLoader.load(getClass().getResource("./view/main.fxml"));
        //设置窗体标题
        primaryStage.setTitle("简易聊天室");
        //将结点放置于窗体中
        primaryStage.setScene(new Scene(root));
        //设置窗体不可编辑
        primaryStage.setResizable(false);
        primaryStage.initStyle(StageStyle.UNDECORATED);
        root.setOnMousePressed(event -> {
            xOffset = event.getSceneX();
            yOffset = event.getSceneY();
        });
        root.setOnMouseDragged(event -> {
            primaryStage.setX(event.getScreenX() - xOffset);
            primaryStage.setY(event.getScreenY() - yOffset);
        });
        //显示窗体
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
